<template>
	<view class="mine-content">
		<u-cell-group :border="false">
			<u-cell :title="item.name" :isLink="true" :value="item.value" center v-for="(item, index) in menuList" :key="index" v-if="item.state" @click="jump(item)">
				<template slot="icon">
					<image :src="item.icon" mode="" class="head"></image>
				</template>
			</u-cell>
		</u-cell-group>
		<u-modal :show="show" title="尚未登录，是否去登录？" showCancelButton :closeOnClickOverlay="true" @close="show = false" @cancel="show = false" @confirm="jumpLogin"></u-modal>
	</view>
</template>

<script>
	export default {
		props: ['userdata'],
		data() {
			return {
				show: false,
				distribution_id: -1,
				menuList: [{
						name: '邀请好友',
						state: 1,
						url: '/pages/inviteFd/inviteFd',
						icon: '/static/mine/fd.png',
						isLogin: true // 是否需要登录
					},
					{
						name: '我的社区',
						state: 1,
						url: '/pages/myArea/myArea',
						icon: '/static/mine/area.png',
						isLogin: true
					},
					{
						name: '账号安全',
						state: 1,
						url: '/pages/idsafeChange/idsafeChange',
						icon: '/static/mine/safe.png',
						isLogin: true
					},
					{
						name: '我的设备',
						state: 1,
						url: '/pages/shebei/shebei',
						icon: '/static/mine/itc.png',
						isLogin: true
					},
					{
						name: '充币',
						state: 1,
						url: '/pages/Charge-money/Charge-money',
						icon: '/static/mine/punching.png',
						isLogin: true
					},
					{
						name: '提币',
						state: 1,
						url: '/pages/Withdraw-money/Withdraw-money',
						icon: '/static/mine/carry.png',
						isLogin: true
					},
					{
						name: '版本更新',
						state: 1,
						url: '/pages/VersionUpdate/VersionUpdate',
						icon: '/static/mine/f5.png',
						isLogin: false,
						value: ''
					}
				]
			};
		},
		// watch: {
		// 	'userdata': function(val) {
		// 		this.distribution_id = val
		// 		this.menuList[0].state = val
		// 	}
		// },
		mounted() {
			this.menuList[this.menuList.length - 1].value = this.$store.state.version
		},
		methods: {
			jumpLogin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
				this.show = false
			},
			jump(e) {
				if(e.isLogin && this.userdata) {
					uni.navigateTo({
						url: e.url
					})
				} else {
					if(!e.isLogin) {
						uni.navigateTo({
							url: e.url
						})
					} else {
						this.show = true
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.mine-content {
		padding: 30rpx;
		padding-top: 26rpx;
	}

	.head {
		width: 40rpx;
		height: 40rpx;
		margin-right: 28rpx;
	}
</style>
